home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / doc / DirectX8 / directx8_c.chm / directx_cpp / glossaryaudio.js < prev    next >
Text File  |  2001-10-19  |  6KB  |  163 lines

  1. /*
  2.     Glossary.js ver 1.00.4 - 6:48 PM 7/24/2001
  3. */
  4. /* Start Localize */
  5. var L_EntryNotFound        = "<SPAN STYLE='color:red; font-weight:bold'>Definition not found.</SPAN>";
  6. var L_PopUpTitle        = "Glossary Term";
  7. /* End Localize */
  8. var bIE                    = 0;
  9. var bNN                    = 0;
  10. var glbPlatformCode        = 0;
  11. var glbBrowserCode        = 0;
  12. var glbVersion            = 0;
  13. var glbSubVersion        = 0;
  14. var uav                 = window.navigator.appVersion;
  15. var uan                 = window.navigator.appName;
  16. if (parseInt(uan.indexOf("Internet Explorer")) >= 0){
  17.     glbBrowserCode = 10;
  18.     glbVersion = parseInt(uav.substring(uav.indexOf("MSIE ") + 5,uav.indexOf("MSIE ") + 7));
  19.     glbSubVersion = parseInt(uav.substring(uav.indexOf("MSIE ") + 7,uav.indexOf("MSIE ") + 9));
  20.     bIE = 1;
  21. }
  22. if (parseInt(uan.indexOf("Netscape")) >= 0){
  23.     glbBrowserCode = 20;
  24.     glbVersion = parseInt(uav.substring(0,4));
  25.     glbSubVersion = parseInt(uav.substring(2,4));
  26.     bNN = 1;
  27. }
  28. if (uav.lastIndexOf("Win") >= 0){
  29.     glbPlatformCode = 10;
  30.     if ((uav.lastIndexOf("Windows 95") >= 0) || (uav.lastIndexOf("Win95") >= 0)){
  31.     glbPlatformCode = 11;
  32.     }
  33.     if ((uav.lastIndexOf("Windows 98") >= 0) || (uav.lastIndexOf("Win98") >= 0)){
  34.     glbPlatformCode = 12;
  35.     }
  36.     if ((uav.lastIndexOf("Windows NT") >= 0) || (uav.lastIndexOf("WinNT") >= 0)){
  37.     glbPlatformCode = 20;
  38.     }    
  39. }
  40. else
  41. {
  42.     if (uav.lastIndexOf("Mac") >= 0){
  43.         glbPlatformCode = 30;    
  44.     }
  45. }
  46. var oPopup             = 0;
  47. var sDBGlossary     = "../dbGlossaryAudio.csv";
  48. var bDataSetComplete = 0;
  49. function InitializePopUp()
  50. {
  51.     if (bIE && ( ( glbVersion >=5 && glbSubVersion >= 5) || (glbVersion >= 6) ) ){
  52.         setPopUp();
  53.         enablePopUp();
  54.     }
  55.     else{
  56.         disablePopUp();
  57.     }
  58. }
  59. function setPopUp(){
  60.     oPopup = window.createPopup();
  61. }
  62. function enablePopUp(){
  63.     var sStyle = "";
  64.     sStyle += '<STYLE> #PopUp{cursor: hand; color: green; text-decoration: underline;}</STYLE>\n';
  65.     sStyle += '<STYLE> #idGlossary{cursor: hand; color: green; text-decoration: underline;}</STYLE>\n';
  66.     var sOnClickEvent = "";
  67.     sOnClickEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="PopUp" EVENT="onclick">';
  68.     sOnClickEvent += '    getTermDefinition(this); return false';
  69.     sOnClickEvent += '</SCR' + 'IPT>\n' ;
  70.     sOnClickEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="idGlossary" EVENT="onclick">';
  71.     sOnClickEvent += '    getTermDefinition(this); return false';
  72.     sOnClickEvent += '</SCR' + 'IPT>\n' ;
  73.     var sOnMouseOverEvent = "";
  74.     sOnMouseOverEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="PopUp" EVENT="onmouseover">';
  75.     sOnMouseOverEvent += '    this.title = "' + L_PopUpTitle + '";'
  76.     sOnMouseOverEvent += '</SCR' + 'IPT>\n' ;
  77.     sOnMouseOverEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="idGlossary" EVENT="onmouseover">';
  78.     sOnMouseOverEvent += '    this.title = "' + L_PopUpTitle + '";'
  79.     sOnMouseOverEvent += '</SCR' + 'IPT>\n' ;
  80.     var sObj = "";
  81.     sObj += '<OBJECT ID="dbGlossary" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83" STYLE="height: 0; width: 0; display:none; position:absolute;" ondatasetcomplete="bDataSetComplete = 1">';
  82.     sObj += '    <PARAM NAME="DataURL" VALUE="' + sDBGlossary + '">';
  83.     sObj += '    <PARAM NAME="UseHeader" VALUE="True">';
  84.     sObj += '    <PARAM NAME="TextQualifier" VALUE="|">';
  85.     sObj += '</OBJECT>\n';
  86.     var sDynLen = "";
  87.     sDynLen = "<DIV ID='idDynamicLength' STYLE='width:400; height:10; overflow:scroll; visibility:hidden; position:absolute;'></DIV></NOBR>";
  88.     window.self.document.write(sStyle);
  89.     window.self.document.write(sOnClickEvent);
  90.     window.self.document.write(sOnMouseOverEvent);
  91.     window.self.document.write(sObj);
  92.     window.self.document.write(sDynLen);
  93. }
  94. function disablePopUp(){
  95.     var sStyle = "";
  96.     sStyle += '<STYLE> #PopUp{color: black; text-decoration: none; cursor="default"}</STYLE>';
  97.     var sStyle1 = "";
  98.     sStyle1 += '<STYLE> #idGlossary{color: black; text-decoration: none; cursor="default"}</STYLE>';
  99.     window.self.document.write(sStyle);
  100.     var sOnClickEvent = "";
  101.     sOnClickEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="PopUp" EVENT="onclick">';
  102.     sOnClickEvent += '    return false;';
  103.     sOnClickEvent += '</SCR' + 'IPT>\n' ;
  104.     window.self.document.write(sStyle);
  105.     window.self.document.write(sOnClickEvent);
  106. }
  107. function getTermDefinition(oObj){
  108.     var ar, sRid;
  109.     if (oObj.href){
  110.         ar = oObj.href.split("#");
  111.         ar.length > 1 ? sRid = ar[1] : sRid = "";
  112.     }
  113.     else{
  114.         sRid = oObj.RID;
  115.     }
  116.     var Gls = getDefinition(sRid);
  117.     if (Gls.found){
  118.         idDynamicLength.innerHTML = Gls.definition;
  119.         Gls.definition = idDynamicLength.innerText;
  120.     }
  121.     var sDef = "<DIV STYLE='width:100%; height:100%; font-family:verdana; font-size: 11; padding: .25em; background-color: #BBDEFC; border-color:#000000 ; border-width:1; border-style:solid;'>";
  122.     sDef += formatTerm(Gls.term);
  123.     sDef += formatDefinition(Gls.definition);
  124.     sDef += "</DIV>\n";
  125.     
  126.     idDynamicLength.innerHTML = sDef;
  127.     var nWidth = idDynamicLength.scrollWidth + 4;
  128.     var nHeight = idDynamicLength.scrollHeight + 4;
  129.     oPopup.document.body.innerHTML = sDef;
  130.     oPopup.show(0, -nHeight, nWidth, nHeight, oObj);
  131. }
  132. function getDefinition(sKey){
  133.     var oRecordSet = dbGlossary.recordset;
  134.     oRecordSet.MoveFirst();
  135.     var def = new DEF();
  136.     for(var i = 0; i < oRecordSet.RecordCount; i++)
  137.     {
  138.         if(sKey == oRecordSet.fields.item('rid').value)
  139.         {
  140.             def.term = oRecordSet.fields.item('key').value;
  141.             def.definition = oRecordSet.fields.item('def').value;
  142.             def.found = 1;
  143.             return def;
  144.         }
  145.         oRecordSet.MoveNext();
  146.     }
  147.     def.term = sKey;
  148.     def.definition = L_EntryNotFound;
  149.     return def;
  150. }
  151. function DEF(){
  152.     this.term = "";
  153.     this.definition = "";
  154.     this.found = 0;
  155. }
  156. function formatTerm(sStr){
  157.         return ("<B>" + sStr + "</B><BR>");
  158. }
  159. function formatDefinition(sStr){
  160.         return (" " + sStr + " ");
  161. }
  162. InitializePopUp();
  163.